package com.arron.principle.singleton.type8;

public class Singleton8 {
    public static void main(String[] args) {
        Singleton singleton1= Singleton.INSTANCE;
        Singleton singleton2= Singleton.INSTANCE;
        System.out.println(singleton1==singleton2);
        System.out.println(singleton1.hashCode());
        System.out.println(singleton2.hashCode());
        singleton1.sayOK();
    }
}
/* 枚举方式实现单例，推荐使用
*
* */
enum Singleton{
    INSTANCE;
    public void sayOK(){
        System.out.println("ok~");
    }
}